using System.Net.Mail;
using System.Threading;
using System.Web.Mvc;

namespace AjaxProgress.Controllers
{
    public class ContactController : Controller
    {
        public ActionResult ContactForm()
        {
            return View();
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult ContactForm(string name,
            string email, string subject, string body)
        {
            Thread.Sleep(2000);

            MailAddress from = new MailAddress(email, name);
            MailAddress to = new MailAddress("keyvan@wrox.com");

            MailMessage mail = new MailMessage(from, to);
            mail.Subject = subject;
            mail.Body = body;

            SmtpClient smtp = new SmtpClient("mail.wrox.com");
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.Send(mail);

            return View();
        }
    }
}
